<%@ page language="java" 
	contentType="text/html; 
	charset=UTF-8"
	pageEncoding="UTF-8"
	import="connectMysql.TestConnect"
	%>
<!DOCTYPE html>
<html>
<head>
	<title>创建作业和考试</title>
	<meta charset="UTF-8">
	<style>
		body {
			font-family: Arial, sans-serif;
		}
		.container {
			width: 500px;
			margin: 0 auto;
			padding: 20px;
			border: 1px solid #ccc;
			border-radius: 5px;
		}
		label {
			display: block;
			margin-bottom: 10px;
		}
		input[type="text"], textarea {
			width: 100%;
			padding: 10px;
			border-radius: 5px;
			border: 1px solid #ccc;
			box-sizing: border-box;
		}
		input[type="file"] {
			margin-top: 10px;
		}
		button {
			display: block;
			margin-top: 20px;
			padding: 10px 20px;
			border-radius: 5px;
			background-color: #4CAF50;
			color: white;
			border: none;
			cursor: pointer;
		}
	</style>
</head>
<body>
	<div class="container">
		<h1>创建作业和考试</h1>
		<form id="createForm"  >
			<label for="type">类型:</label>
			<select id="type">
				<option value="assignment">作业</option>
				<option value="exam">考试</option>
			</select>
			
			<label for="name">名称:</label>
			<input type="text" id="name" required>

			<label for="startTime">开始时间:</label>
			<input type="datetime-local" id="startTime" required>
			
			<label for="endTime">结束时间:</label>
			<input type="datetime-local" id="endTime" required>
			
			<label for="description">作业题:</label>
			<textarea id="description" rows="4" required></textarea>
			
			<label for="file">上传文件:</label>
			<input type="file" id="file" accept=".pdf,.doc,.docx,.ppt,.pptx">
			
			<button type="button" onclick="create()">新建作业</button>
		</form>
	</div>
	<%
	String userid=request.getParameter("id");
	String classname=request.getParameter("classname");
	String class_id=connectMysql.TestConnect.class_name_to_id(classname);
	%>
	<script>
		function create() {
			var type = document.getElementById("type").value;
			var name = document.getElementById("name").value;
			var startTime = document.getElementById("startTime").value;
			var endTime = document.getElementById("endTime").value;
			var description = document.getElementById("description").value;
			var file = document.getElementById('file')
			
			var fileName = file.name; // 获取文件名
			
			
			var file = document.getElementById("file").value;
			event.preventDefault();
			window.location="init_work_check.jsp?type="+type+"&startTime="+startTime+
					"&name="+name+"&end="+endTime+"&desc="+description+"&class_id=<%=class_id%>&user_id=<%=userid%>&class_name=<%=classname%>";
		}
	</script>
</body>
</html>

